package com.hksj.Intelligentmanagement.controller;

import com.hksj.Intelligentmanagement.common.Constants;
import com.hksj.Intelligentmanagement.common.Rest;
import com.hksj.Intelligentmanagement.dto.NurseLevelDTO;
import com.hksj.Intelligentmanagement.dto.NurseLevelWithNurseDTO;
import com.hksj.Intelligentmanagement.service.NurseLevelService;
import com.hksj.Intelligentmanagement.vo.NurseLevelVo;
import com.hksj.Intelligentmanagement.vo.NurseLevelWithNurseVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "护士等级管理")
@RestController
@RequestMapping("/api/nurseLevel")
public class NurseLevelController {
    @Autowired
    private NurseLevelService nurseLevelService;

    @ApiOperation("新增护士等级")
    @PostMapping("/createNurseLevel")
    public Rest createNurseLevel(@RequestBody @Validated(NurseLevelDTO.Create.class) NurseLevelDTO nurseLevelDTO){
        nurseLevelDTO.setType(Constants.TYPE_NURSE);
        return nurseLevelService.create(nurseLevelDTO);
    }

    @ApiOperation("修改护士等级")
    @PostMapping("/updateNurseLevel")
    public Rest updateNurseLevel(@RequestBody @Validated(NurseLevelDTO.Update.class) NurseLevelDTO nurseLevelDTO){
        return nurseLevelService.updateNurseLevel(nurseLevelDTO);
    }

    @ApiOperation("删除护士等级")
    @DeleteMapping("/deleteNurseLevel/{id}")
    public Rest deleteNurseLevel(@PathVariable("id") String id){
        return nurseLevelService.delete(id);
    }

    @ApiOperation("查询护士等级列表")
    @PostMapping("/listNurseLevel")
    public Rest<List<NurseLevelVo>> listNurseLevel(@RequestBody NurseLevelDTO nurseLevelDTO){
        nurseLevelDTO.setType(Constants.TYPE_NURSE);
        return Rest.ok(nurseLevelService.listNurseLevel(nurseLevelDTO));
    }

    @ApiOperation("查询护士等级列表和人员信息")
    @PostMapping("/listNurseLevelWithNurse")
    public Rest<List<NurseLevelWithNurseVo>> listNurseLevelWithNurse(@RequestBody NurseLevelWithNurseDTO nurseLevelWithNurseDTO){
        nurseLevelWithNurseDTO.setType(Constants.TYPE_NURSE);
        return Rest.ok(nurseLevelService.listNurseLevelWithNurse(nurseLevelWithNurseDTO));
    }
}
